<template>
  <div style="height:100%;width:100%;position:relative;" ref="maindev">
      <div class="pagetop">
          <div class="pagetop-content">
              <table style="width:100%;font-size:12px;max-width:1268px;" border="0">
                  <tr>
                      <td align="right">区间</td>
                      <td colspan="3">
                          <el-date-picker v-model="datetime1" type="date" placeholder="开始日期" value-format="yyyy-MM-dd 00:00:00" size="mini" :clearable="false" style="width:105px"></el-date-picker> 至
                          <el-date-picker v-model="datetime2" type="date" placeholder="结束日期" value-format="yyyy-MM-dd 23:59:59" size="mini" :clearable="false" style="width:105px"></el-date-picker>
                      </td>
                      <td align="right" width="40px">时间段</td>
                      <td colspan="5">
                          <el-time-picker v-model="timevalue1" placeholder="开始时间" style="height:25px;line-height:23px;width:90px" value-format="HH:mm" format='HH:mm'></el-time-picker> 至
                          <el-time-picker v-model="timevalue2" placeholder="结束时间" style="height:25px;line-height:23px;width:90px" value-format="HH:mm" format='HH:mm'></el-time-picker>
                          <el-checkbox true-label="1" false-label="0" v-model="exceptflag">剔除</el-checkbox>
                      </td>
                      <td colspan="3" align="right">
                          <el-radio-group v-model="datetype" style="width: 300px">
                              <el-radio label="1">接收时间</el-radio>
                              <el-radio label="2">样本日期</el-radio>
                              <el-radio label="3">生成时间</el-radio>
                              <el-radio label="4">审核时间</el-radio>
                          </el-radio-group>
                      </td>
                      <td align="right" style="width:50px">查询模版</td>
                      <td>
                          <el-select v-model="querymod" placeholder="" @change="querymodChange($event)" clearable filterable style="width:110px">
                              <el-option v-for="(item,index) in querymodOption" :key="index" :value="item.value" :label="item.label"></el-option>
                          </el-select>
                          <el-button class="top-btn" @click.native="btnSavequerymod">保存</el-button>
                          <el-button class="top-btn" @click.native="btnDelquerymod">删除</el-button>
                      </td>

                  </tr>
                  <tr>
                      <td align="right">检验医院</td>
                      <td colspan="3">
                          <rm-ddl-common datatype="hospital" dataname="医院" v-model="chkhospcode" width="240px" @change="chkhospcodeChange"></rm-ddl-common>
                      </td>

                      <td align="right" width="65">检验科室</td>
                      <td colspan="2">
                          <el-select v-model="chkdeptno" @dblclick.native="popMultipleChk(chkdeptno,'chkdeptno',labdeptOption,'检验科室选择')" filterable clearable style="width:100%">
                              <el-option v-for="(item,index) in labdeptOption" :key="index" :value="item.data" :label="item.display">
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right" width="65">检验组别</td>
                      <td colspan="2">
                          <el-select v-model="chklabgroup" @dblclick.native="popMultipleChk(chklabgroup,'chklabgroup',labgroupOption,'请选择检验组别')" filterable clearable style="width:100%">
                              <el-option v-for="(item,index) in labgroupOption" :key="index" :value="item.data" :label="item.display"></el-option>
                          </el-select>
                      </td>
                      <td align="right" width="65">送检医院</td>
                      <td colspan="2">
                          <el-select v-model="sendhospcode" @dblclick.native="popMultipleChk(sendhospcode,'sendhospcode',hospOption,'请选择送检医院')" filterable clearable style="width:100%">
                              <el-option v-for="(item,index) in hospOption" :key="index" :value="item.data" :label="item.display"></el-option>
                          </el-select>
                      </td>
                      <td align="right" width="65">科室</td>
                      <td colspan="2">
                          <el-select v-model="deptno" @dblclick.native="popMultipleChk(deptno,'deptno',deptOption,'科室选择')" filterable remote clearable style="width:70%">
                              <el-option v-for="(item,index) in deptOption" :key="index" :value="item.data" :label="item.display">
                              </el-option>
                          </el-select>
                          <el-checkbox true-label="1" false-label="0" v-model="emerflag">急诊</el-checkbox>
                      </td>
                  </tr>
                  <tr>
                      <td align="right">报告单元</td>
                      <td colspan="3">
                          <el-select v-model="rptunitid" @dblclick.native="popMultipleChk(rptunitid,'rptunitid',rptunitOption,'请选择报告单元')" filterable clearable remote style="width:100%">
                              <el-option v-for="(item,index) in rptunitOption" :key="index" :value="item.data" :label="item.display"></el-option>
                          </el-select>
                      </td>
                      <td align="right">申请医生</td>
                      <td colspan="2">
                          <rm-ddl-common datatype="doctor" dataname="医生" v-model="doctorno" width="100%" @change="doctornoChange"></rm-ddl-common>
                      </td>
                      <td align="right">性别</td>
                      <td colspan="2">
                          <el-select v-model="patsex" style="width:100%" clearable>
                              <el-option label="男" value="1"></el-option>
                              <el-option label="女" value="2"></el-option>
                              <el-option label="未知" value="3"></el-option>
                          </el-select>
                      </td>
                      <td align="right">病人类型</td>
                      <td colspan="2">
                          <el-select v-model="pattype" @dblclick.native="popMultipleChk(pattype,'pattype',pattypeOption,'病人类型选择')" filterable clearable style="width:100%">
                              <el-option v-for="(item,index) in pattypeOption" :value="item.data" :label="item.display" :key="index"></el-option>
                          </el-select>
                      </td>
                      <td align="right">病区</td>
                      <td colspan="2">
                          <el-select v-model="wardno" @dblclick.native="popMultipleChk(wardno,'wardno',wardOption,'病区选择')" remote filterable clearable style="width:186px;">
                              <el-option v-for="(item,index) in wardOption" :key="index" :value="item.data" :label="item.display">
                              </el-option>
                          </el-select>
                      </td>
                  </tr>
                  <tr>
                      <td align="right">申请项目</td>
                      <td colspan="3">
                          <el-select v-model="reqitem" @dblclick.native="popMultipleChk(reqitem,'reqitem',reqitemOption,'申请项目选择')" style="width:100%" remote filterable clearable>
                              <el-option v-for="(item,index) in reqitemOption" :key="index" :value="item.data" :label="item.display">
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right">检验医生</td>
                      <td colspan="2">
                          <rm-ddl-common datatype="userinfo" kindno="1" dataname="检验医生" v-model="reportusername" width="100%" @change="reportuserChange"></rm-ddl-common>
                      </td>
                      <td align="right">单元组合</td>
                      <td colspan="2">
                          <el-select v-model="unitgroup" @dblclick.native="popMultipleChk(unitgroup,'unitgroup',rptunitGroupOption,'单元组合选择')" style="width:100%" filterable clearable>
                              <el-option v-for="(item,index) in rptunitGroupOption" :key="index" :value="item.data" :label="item.display">
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right">费别大类</td>
                      <td colspan="2">
                          <el-select v-model="chargetype" @dblclick.native="popMultipleChk(chargetype,'chargetype',chargetypeoption,'费别选择')" filterable clearable style="width:100%">
                              <el-option v-for="(item,index) in chargetypeoption" :key="index" :value="item.data" :label="item.display">
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right">类别</td>
                      <td colspan="2">
                          <el-select v-model="reqtype" style="width:186px;" filterable clearable>
                              <el-option value="C" label="检验"></el-option>
                              <el-option value="H" label="输血"></el-option>
                          </el-select>
                      </td>
                  </tr>
                  <tr>
                      <td align="right">所属院区</td>
                      <td colspan="3">
                          <el-select v-model="pathospcode" @dblclick.native="popMultipleChk(pathospcode,'pathospcode',hospOption,'请选择所属院区')" remote filterable clearable style="width:100%">
                              <el-option v-for="(item,index) in hospOption" :key="index" :value="item.data" :label="item.display"></el-option>
                          </el-select>
                      </td>
                      <td align="right">执行科室</td>
                      <td colspan="2">
                          <rm-ddl-common datatype="dept" kindno="perform" dataname="科室" v-model="peformdept" width="100%" @change="peformdeptChange"></rm-ddl-common>
                      </td>
                      <td align="right">状态</td>
                      <td colspan="2">
                          <el-select v-model="reqstat" style="width:100%" filterable clearable>
                              <el-option value="0" label="申请"></el-option>
                              <el-option value="1" label="打印"></el-option>
                              <el-option value="12" label="打印复核"></el-option>
                              <el-option value="2" label="采样"></el-option>
                              <el-option value="3" label="护士站送出"></el-option>
                              <el-option value="31" label="已下载"></el-option>
                              <el-option value="4" label="检验科签收"></el-option>
                              <el-option value="41" label="工作组签收"></el-option>
                              <el-option value="42" label="上机"></el-option>
                              <el-option value="43" label="组内交接"></el-option>
                              <el-option value="44" label="已分样"></el-option>
                              <el-option value="45" label="外送送出"></el-option>
                              <el-option value="01" label="申请单已被审核"></el-option>
                              <el-option value="02" label="申请单审核未通过"></el-option>
                              <el-option value="03" label="复审通过"></el-option>
                              <el-option value="04" label="复审未通过"></el-option>
                          </el-select>
                      </td>
                      <td align="right">分单类别</td>
                      <td colspan="2">
                          <el-select v-model="groupna" @dblclick.native="popMultipleChk(groupna,'groupna',reqgroupOption,'分单类别')" style="width:100%" filterable clearable>
                              <el-option v-for="(item,index) in reqgroupOption" :key="index" :value="item.data" :label="item.display">
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right">年龄区间</td>
                      <td colspan="2">
                          <el-input v-model="agelow" style="width:40px"></el-input> -
                          <el-input v-model="ageupper" style="width:40px"></el-input>
                      </td>
                  </tr>
                  <tr>
                      <td align="right">标本号区间</td>
                      <td colspan="3">
                          <el-input v-model="sampleno" style="width:100%"></el-input>
                      </td>
                      <td align="right">审核医生</td>
                      <td colspan="2">
                          <rm-ddl-common datatype="userinfo" kindno="1" dataname="审核医生" v-model="rechkusername" width="100%" @change="rechkuserChange"></rm-ddl-common>
                      </td>
                      <td align="right">病人诊断</td>
                      <td colspan="2">
                          <el-input v-model="diagnose" clearable></el-input>
                      </td>
                      <td align="right">诊断ICD</td>
                      <td colspan="2">
                          <el-input v-model="diagnoseicd" clearable></el-input>
                      </td>
                      <td align="right">分单前缀</td>
                      <td colspan="2">
                          <el-select v-model="barcode_head" @dblclick.native="popMultipleChk(barcode_head,'barcode_head',barcode_headOption,'分单前缀选择')" filterable clearable style="width:186px;">
                              <el-option v-for="(item,index) in barcode_headOption" :value="item.data" :label="item.display" :key="index"></el-option>
                          </el-select>
                      </td>
                  </tr>
                  <tr>
                      <td align="right">统计项目</td>
                      <td colspan="12">
                          <div v-if="infoitem==''" @click="Btncountitem">
                              <span style="color:red;cursor:pointer;font-size:15px">点击该位置选择统计项目</span>
                          </div>
                          <div v-else>
                              <div @click="Btncountitem" style="width:100%;cursor:pointer;color:#409EFF"><u>{{infoitem}}</u></div>
                              <el-input v-model="infocode" readonly v-show="false"></el-input>
                          </div>
                      </td>
                      <td align="right">混样报告</td>
                      <td colspan="2">
                          <el-select v-model="sel_mixrpt" placeholder="请选择" style="width:186px;">
                              <el-option key="0" label="全部报告" value="0"></el-option>
                              <el-option key="1" label="混样主报告" value="1"></el-option>
                              <el-option key="2" label="混样明细报告" value="2"></el-option>
                          </el-select>
                      </td>
                  </tr>
                  <tr>
                      <td colspan="16" align="left">
                          <div class="mychkclass">
                              &nbsp;&nbsp;
                              <el-checkbox true-label="1" false-label="0" v-model="chk_norec" style="margin-left: 5px">未接收</el-checkbox>
                              <el-checkbox true-label="1" false-label="0" v-model="chk_abandon">作废退回</el-checkbox>
                              <el-checkbox true-label="1" false-label="0" v-model="chk_notcharge">未计价</el-checkbox>
                              <el-checkbox true-label="1" false-label="0" v-model="chk_notrpt">未报告</el-checkbox>
                              <el-checkbox true-label="1" false-label="0" v-model="chk_deptinput">科内录入</el-checkbox>
                              <el-checkbox true-label="1" false-label="0" v-model="chk_bact">无纸化微生物</el-checkbox>
                              <span style="font-weight:bold">的标本不统计</span>
                              <span style="font-weight:bold">
                                  <el-divider direction="vertical"></el-divider>统计包含
                              </span>
                              <el-checkbox true-label="1" false-label="0" v-model="chk_workdays">工作日</el-checkbox>
                              <el-checkbox true-label="1" false-label="0" v-model="chk_holiday">节假日</el-checkbox>
                              <el-checkbox true-label="1" false-label="0" v-model="chk_saturday">周六</el-checkbox>
                              <el-checkbox true-label="1" false-label="0" v-model="chk_sunday">周日</el-checkbox>
                              <el-checkbox v-model="chk_cnt">项次</el-checkbox>
                              <el-checkbox v-model="chk_amt">金额</el-checkbox>
                              <el-divider direction="vertical"></el-divider>
                              <el-checkbox true-label="1" false-label="0" v-model="chk_detail">按小项统计</el-checkbox>
                              <el-checkbox true-label="1" false-label="0" v-model="showsum2">显示小计</el-checkbox>
                              <el-checkbox true-label="1" false-label="0" v-model="showsum1">显示合计</el-checkbox>
                          </div>
                      </td>
                  </tr>
              </table>
              <div style="text-align: right;padding-right: 5px;">
                  <el-button @click.native="QueryData()" v-has="'PINQUERY'" type="primary" icon="el-icon-search">查询</el-button>
                  <el-button @click.native="BtnExport" icon="el-icon-upload2">导出</el-button>
                  <!--<el-button @click.native="BtnSort" icon="el-icon-sort">排序</el-button>
                  <el-button @click.native="BtnClear" icon="el-icon-close">清除</el-button>-->
                  <el-button @click.native="BtnPrint(1)" v-has="'PPRINT'" icon="el-icon-printer">打印</el-button>
                  <el-button @click.native="BtnPrint(3)" v-if="$tool.getSession(this.$tool.loginuserno)=='admin'" icon="el-icon-printer">样式调整</el-button>
              </div>
          </div>
      </div>
      <div class="pagecenter">
          <vxe-table show-overflow ref="xTable1" height="auto" :loading="loading" :data.sync="tableData" class="editable-footer" :footer-method="footerMethod" :footer-cell-class-name="footerCellClassName" :cell-class-name="CellClassName" border size="mini" show-header-overflow highlight-current-row highlight-hover-row show-footer resizable stripe>
              <vxe-table-column :field="item.field" :title="item.title" :key="item.field" width="160" header-align="center" v-for="item in tableColumns"></vxe-table-column>
              <vxe-table-column field="cp_cnt" title="项次" width="160" header-align="center" v-if="chk_cnt"></vxe-table-column>
              <vxe-table-column field="cp_amt" title="金额" width="160" header-align="center" v-if="chk_amt"></vxe-table-column>
              <vxe-table-column field="cp_rs" title="人数" width="160" header-align="center" v-if="chk_personnum"></vxe-table-column>
              <vxe-table-column field="cp_samplecnt" title="样本数" width="160" header-align="center" v-if="chk_smpnum"></vxe-table-column>
              <vxe-table-column field="cp_itemrptcnt" title="对应报告项目数" width="160" header-align="center" v-if="chk_irptnum"></vxe-table-column>
              <vxe-table-column field="cp_itemfrecnt" title="样本数*对应报告项目数" width="160" header-align="center" v-if="chk_irtnum"></vxe-table-column>
          </vxe-table>
      </div>

      <el-dialog title="统计项目" :visible.sync="dialogcountItem" width="1000px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false">
          <div style="width:100%;height:40px;">
              <div style="width:65%;float:left">
                  <table class="table1style">
                      <tr>
                          <td>统计模版</td>
                          <td>
                              <el-select v-model="txtstasticsmod" placeholder="" @change="stasticmodChange($event)" @clear="resetStasticItem" clearable>
                                  <el-option v-for="(item,index) in stasticsmodOption" :key="index" :value="item.value" :label="item.label"></el-option>
                              </el-select>
                          </td>
                          <td>
                              <el-button @click.native="btnSaveStaticmod">保存</el-button>
                              <el-button @click.native="btnDelStaticmod">删除</el-button>
                          </td>
                      </tr>

                  </table>
              </div>
              <div style="width:35%;float:left;padding-top:2px;position:absolute;right:0px">
                  <el-button icon="el-icon-top" @click="SetFirst()">首位</el-button>
                  <el-button icon="el-icon-top-right" @click="SetUp()">上移</el-button>
                  <el-button icon="el-icon-bottom-right" @click="SetDown()">下移</el-button>
                  <el-button icon="el-icon-bottom" @click="SetLast()">末位</el-button>
              </div>
          </div>
          <div style="width:99.5%;height:34px;border:1px solid #ccc;padding:5px;">
              <span style="margin-right:40px">其他统计项</span>
              <el-checkbox true-label="1" false-label="0" v-model="chk_personnum">人数</el-checkbox>
              <el-checkbox true-label="1" false-label="0" v-model="chk_smpnum">样本数</el-checkbox>
              <el-checkbox @change="rptChange('chk_irptnum')" v-model="chk_irptnum">对应报告项目数</el-checkbox>
              <el-checkbox @change="rptChange('chk_irtnum')" v-model="chk_irtnum">样本数*对应报告项目数</el-checkbox>
          </div>
          <div style="width:100%;height:400px;margin-top:5px">
              <div style="width:70%;height:100%;float:left;overflow:auto;border:1px solid #ccc;">
                  <div id='left_nav' class="left_nav">
                      <div @click="showseq=1" :class="showseq == 1 ? 'active' : ''" ref="left1">
                          1 申请信息
                      </div>
                      <div @click="showseq=2" :class="showseq == 2 ? 'active' : ''" ref="left2">
                          2 送检信息
                      </div>
                      <div @click="showseq=3" :class="showseq == 3 ? 'active' : ''" ref="left3">
                          3 检验信息
                      </div>
                      <div @click="showseq=4" :class="showseq == 4 ? 'active' : ''" ref="left4">
                          4 病人信息
                      </div>
                      <div @click="showseq=5" :class="showseq == 5 ? 'active' : ''" ref="left5">
                          5 检验日期
                      </div>
                  </div>
                  <div id='right_nav' class="right_nav">
                      <table class="table1style" style="width:100%;padding:10px">
                          <tr v-show="showseq==1">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'申请类别','chkexamgroup')" v-model="chkexamgroup">申请类别</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'标本类型','chkitemspecimen')" v-model="chkitemspecimen">标本类型</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'项目代码','chkitemcode')" v-model="chkitemcode">项目代码</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'项目名称','chkitemname')" v-model="chkitemname">项目名称</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==1">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'单价','chkitemprice')" v-model="chkitemprice">单价</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'计价','chkitemchargeflag')" v-model="chkitemchargeflag">计价</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'费别大类','chkpatchargetype')" v-model="chkpatchargetype">费别大类</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'费别','chkpatchargeno')" v-model="chkpatchargeno">费别</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==1">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'申请日期','chkreqdt')" v-model="chkreqdt">申请日期</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'分单类别','chkgroupna')" v-model="chkgroupna">分单类别</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'销售','chksaleman')" v-model="chksaleman">销售</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'采样用户','chksampleuser')" v-model="chksampleuser">采样用户</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==1">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'分单条码前缀','chkbarcode_head')" v-model="chkbarcode_head">分单条码前缀</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,hisrefcodelist[0],'chkhisrefcol1')" v-model="chkhisrefcol1">{{hisrefcodelist[0]}}</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,hisrefcodelist[1],'chkhisrefcol2')" v-model="chkhisrefcol2">{{hisrefcodelist[1]}}</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,hisrefcodelist[2],'chkhisrefcol3')" v-model="chkhisrefcol3">{{hisrefcodelist[2]}}</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==2">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'送检医院代码','chksendhospcode')" v-model="chksendhospcode">送检医院代码</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'送检医院名称','chksendhospitalname')" v-model="chksendhospitalname">送检医院名称</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'送检医院简称','chksendhospitalna')" v-model="chksendhospitalna">送检医院简称</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==2">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'送检科室','chksenddeptno')" v-model="chksenddeptno">送检科室</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病区','chkpatwardno')" v-model="chkpatwardno">所在病区</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'送检医生','chksenddoctor')" v-model="chksenddoctor" v-has="'PQREQDOC'">送检医生</el-checkbox>
                              </td>
                              <!--<td>
                                  <el-checkbox @change="chkcountitem($event,'送检目的','chksendreason')" v-model="chksendreason">执行科室</el-checkbox>
                              </td> -->
                          </tr>
                          <tr v-show="showseq==3">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'检验院区','chkexamhospcode')" v-model="chkexamhospcode">检验院区</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'检验科室','chkexamdeptno')" v-model="chkexamdeptno">检验科室</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'检验组别','chkexlabgroup')" v-model="chkexlabgroup">检验组别</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'报告单元','chkexamtptunit')" v-model="chkexamtptunit">报告单元</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==3">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'审核医生','chkverifydoctor')" v-model="chkverifydoctor">审核医生</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'检验医生','chkreportdoctor')" v-model="chkreportdoctor">检验医生</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==4">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'性别','chkpatsex')" v-model="chkpatsex">性别</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病人类型','chkpattype')" v-model="chkpattype">病人类型</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病人','chkpatname')" v-model="chkpatname">病人</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'诊断','chkpatdianose')" v-model="chkpatdianose">诊断</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==4">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'诊断ICD','chkpatdianoseicd')" v-model="chkpatdianoseicd">诊断ICD</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病人ID','chkpatid')" v-model="chkpatid">病人ID</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病人号','chkpatno')" v-model="chkpatno">病人号</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'床位','chkbedno')" v-model="chkbedno">床位</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==4">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'民族','chkpat_nationna')" v-model="chkpat_nationna">民族</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==5">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'年','chkdateyear')" v-model="chkdateyear">年</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'月','chkdatemonth')" v-model="chkdatemonth">月</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'日','chkdateday')" v-model="chkdateday">日</el-checkbox>
                              </td>
                          </tr>
                      </table>
                  </div>
              </div>
              <div style="width:29%;height:100%;float:left;margin-left:5px;overflow:auto;">
                  <vxe-table show-overflow ref="xTable2" height="auto" :data.sync="staticitemData" @current-change="dialogItemChange" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe>
                      <vxe-table-column type="index" title="NO." width="50"></vxe-table-column>
                      <vxe-table-column field="countitem" title="统计项目" width="160" sortable header-align="center"></vxe-table-column>
                      <vxe-table-column field="countcode" title="统计代码" width="160" sortable header-align="center"></vxe-table-column>
                  </vxe-table>
              </div>
          </div>
          <span slot="footer" class="dialog-footer">
              <el-button type="primary" @click="dialogcountItemsave">确 定</el-button>
              <el-button @click="dialogcountItem = false">取 消</el-button>
          </span>
      </el-dialog>

      <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="multichktitle" :visible.sync="dialogMultipleVisible" :destroy-on-close="true" v-if="dialogMultipleVisible">
          <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname" :datatype="multidatatype" :rightValue="multivalue" @change="closedialog"></rm-SqlMultiple>
      </el-dialog>
  </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils";
export default {
  name: "LIS611",
  data() {
      return {
          //筛选项目
          datename: "标本日期",
          datecode: "sam",
          datetime1: "",
          datetime2: "",
          datetype: "1",
          chkhospcode: "",
          hospcode: "",
          hospOption: [],
          unitgroup: "",
          rptunitGroupOption: [],
          chkdeptno: "",
          deptOption: [],
          labdeptOption: [],
          chklabgroup: "",
          labgroupOption: [],
          chargetype: "",
          sendhospcode: "",
          chkdoctor: "",
          querymod: "",
          querymodOption: [],
          sampleno: "",
          timevalue1: "00:00",
          timevalue2: "23:59",
          exceptflag: "0",

          deptno: "",
          wardno: "",
          wardOption: [],
          rptunitid: "",
          doctorno: "",
          patsex: "",
          emerflag: "",
          pattype: "",
          pattypeOption: [],
          barcode_head: "",
          barcode_headOption: [],
          diagnose: "",
          diagnoseicd: "",
          infoitem: "",
          infocode: "",
          peformdept: "",
          pathospcode: "",
          reqtype: "",
          reqstat: "",
          groupna: "",
          reqgroupOption: [],
          reqitem: "",
          reqitemOption: [],
          chargetypeoption: [],
          rptunitOption: [],
          reportusername: "",
          rechkusername: "",
          multichktitle: "",
          loading: false,
          agelow: "",
          ageupper: "",
          showsum2: "0",
          showsum1: "0",
          //筛选列
          dialogcountItem: false,
          chksendhospcode: false,
          chksendhospitalname: false,
          chksendhospitalna: false,
          chksenddeptno: false,
          chksenddoctor: false,
          chksendreason: false,
          chkexamhospcode: false,
          chkexlabgroup: false,
          chkviewhosp: false,
          chkexamdeptno: false,
          chkexamgroup: false,
          chkgroupna: false,
          chkreqdt: false, //申请日期
          chkitemcode: false,
          chkexamtptunit: false,
          chkverifydoctor: false,
          chkreportdoctor: false,
          chksaleman: false,
          chksampleuser: false,
          chkbarcode_head: false,
          chkexaminstrument: false,
          chkexammemo: false,
          chkpatwardno: false,
          chkpatname: false,
          chkpatdianose: false,
          chkpatdianoseicd: false,
          chkpatsex: false,
          chkpattype: false,
          chkpatchargetype: false,
          chkpatchargeno: false,
          chkpatnation: false,
          chkitemspecimen: false,
          chkitemchargeflag: false,

          chkitemname: false,
          chkitemprice: false,
          chkitemstatisticcode: false,
          chkdateyear: false,
          chkdatemonth: false,
          chkdateday: false,
          chk_personnum: false,
          chk_smpnum: false,
          chk_irptnum: false,
          chk_irtnum: false,
          chk_itemrechknum: false,
          chkpatid: false,
          chkpatno: false,
          chkbedno: false,
          chkpat_nationna: false,
          chkhisrefcol1: false,
          chkhisrefcol2: false,
          chkhisrefcol3: false,
          sel_mixrpt: "0", //混样报告
          chk_norec: "0",
          chk_abandon: "0",
          chk_notcharge: "0",
          chk_notrpt: "0",
          chk_deptinput: "0",
          chk_bact: "1",
          chk_workdays: "1",
          chk_holiday: "1",
          chk_saturday: "1",
          chk_sunday: "1",
          chk_cnt: true,
          chk_amt: true,
          chk_detail: "0",
          showseq: 1,
          staticitemData: [],
          stasticsmodOption: [],
          txtstasticsmod: "",
          //表格内容
          totalData: [],
          tableData: [],
          tableColumns: [],
          tableColumn: [],
          currentindex: -1,
          //多选弹窗
          dialogMultipleVisible: false,
          option1: [],
          option2: [],
          fieldname: "",
          hisrefcodelist: [],
          multidatatype: "", //多选弹窗类型
          multivalue: "", //多选弹窗值
          // 导出统计条件用
          chkhospname: "",
          doctorname: "",
          reportuserrealname: "",
          peformdeptname: "",
          rechkuserrealname: "",
      };
  },
  created() {
      //第一次加载选项内容较少的
      this.QueryOption(1);
      this.InitData();
  },
  mounted() {
      //选项内容多的等页面渲染完再加载
      this.QueryOption(2);
  },
  methods: {
      QueryData() {
          if (this.infocode == "") {
              this.$alert("请选择统计项目!");
              return false;
          }
          this.loading = true;
          this.tableColumns = [];
          this.totalData = [];
          this.tableData = [];
          this.$tool
              .request({
                  url: "LIS/LIS6/LIS611",
                  method: "post",
                  timeout: 600000,
                  data: {
                      action: "QueryAll",
                      datetype: this.datetype,
                      datetime1: this.datetime1,
                      datetime2: this.datetime2,
                      pattype: this.pattype,
                      barcode_head: this.barcode_head,
                      rptunitid: this.rptunitid,
                      deptno: this.deptno,
                      wardno: this.wardno,
                      performdept: this.peformdept,
                      doctorno: this.doctorno,
                      reqtype: this.reqtype,
                      patsex: this.patsex,
                      groupna: this.groupna,
                      chkdeptno: this.chkdeptno,
                      chklabgroup: this.chklabgroup,
                      hospcode: this.chkhospcode,
                      reportusername: this.reportusername,
                      rechkusername: this.rechkusername,
                      diagnose: this.diagnose,
                      diagnoseicd: this.diagnoseicd,
                      sendhospcode: this.sendhospcode,
                      pathospcode: this.pathospcode,
                      reqitem: this.reqitem,
                      reqstat: this.reqstat,
                      infocode: this.infocode,
                      infoitem: this.infoitem,
                      emerflag: this.emerflag ? "1" : "0",
                      unitgroup: this.unitgroup,
                      sel_mixrpt: this.sel_mixrpt, //混样报告
                      chk_norec: this.chk_norec,
                      chk_abandon: this.chk_abandon,
                      chk_notcharge: this.chk_notcharge,
                      chk_notrpt: this.chk_notrpt,
                      chk_deptinput: this.chk_deptinput,
                      chk_bact: this.chk_bact,
                      chk_workdays: this.chk_workdays,
                      chk_holiday: this.chk_holiday,
                      chk_saturday: this.chk_saturday,
                      chk_sunday: this.chk_sunday,
                      exceptflag: this.exceptflag,
                      timevalue1: this.timevalue1,
                      timevalue2: this.timevalue2,
                      chargetype: this.chargetype,
                      chk_detail: this.chk_detail, 
                      agelow: this.agelow, 
                      ageupper: this.ageupper,
                      sampleno: this.sampleno,
                      showsum2: this.showsum2, 
                      showsum1: this.showsum1, 
                      chk_irptnum: this.chk_irptnum ? "1" : "0",
                      chk_irtnum: this.chk_irtnum ? "1" : "0",
                      chk_smpnum: this.chk_smpnum ? "1" : "0",
                      chk_personnum: this.chk_personnum ? "1" : "0",
                  },
              })
              .then((res) => {
                  if (res.errormsg) {
                      this.$alert(res.errormsg);
                      return;
                  }
                  this.loading = false;
                  //this.tableData = res.Data.Data;
                  this.tableColumns = res.Data.Cols;
                  this.totalData = res.Data.Data;

                  this.tableData = [];
                  var temparr = [];
                  for (let i = 0; i < res.Data.Data.length; i++) {
                      var row = res.Data.Data[i];
                      // for (var pkey in row) {
                      //     if (["cp_amt", "cp_cnt", "cp_rs", "cp_samplecnt", "cp_redocnt"].includes(pkey)) continue;
                      //     if (i == 0) {
                      //         temparr.push({ field: pkey, label: row[pkey] });
                      //         break;
                      //     }
                      //     var findrow = temparr.find(item => item.field == pkey);
                      //     if (findrow && findrow.label == row[pkey]) row[pkey] = "";
                      //     else if (findrow) findrow.label = row[pkey];
                      // }

                      this.tableData.push(row);
                  }
                  //this.tableData = this.DealDataStatic(res.Data.Data, res.select2, res.select);
                  this.$pub.Log("LIS611:" + res.sqlstr);
                  // if(this.chk_personnum) this.tableColumns.push({field:"cp_rs",title:"人数",width:"160px"});
                  // if(this.chk_smpnum) this.tableColumns.push({field:"cp_samplecnt",title:"样本数",width:"160px"});
              });
      },
      //分两批加载，防止一次加载太多导致页面初始化渲染时间太长
      QueryOption(type) {
          if (type == 1) {
              this.$tool
                  .request({
                      url: "LIS/LIS6/LIS611",
                      method: "post",
                      data: {
                          action: "initOption",
                      },
                  })
                  .then((res) => {
                      this.pattypeOption = res.pattypeOption;
                      this.barcode_headOption = res.barcode_headOption;
                      this.labdeptOption = res.labdeptOption;

                      this.rptunitGroupOption = res.rptunitGroupOption;
                      this.reportcommOption = res.reportcommOption;

                      this.labgroupOption = res.labgroupOption;
                      this.reqgroupOption = res.reqgroupOption;

                      this.chargetypeoption = res.chargetypeoption;
                      this.datetime1 = res.datetime + " 00:00:00";
                      this.datetime2 = res.datetime + " 23:59:59";
                      this.hisrefcodelist = res.hisreflist;
                      console.log("this.hisrefcodelist", this.hisrefcodelist);
                  });
          } else {
              this.$tool
                  .request({
                      url: "LIS/LIS6/LIS611",
                      method: "post",
                      data: {
                          action: "loadOption",
                      },
                  })
                  .then((res) => {
                      // 因为怕开局加载页面速度太慢，这几个选项没有开局就加载，所以需要这里给重新加载下
                      this.deptOption = res.deptOption;
                      this.hospOption = res.hospOption;
                      this.rptunitOption = res.rptunitOption;
                      this.wardOption = res.wardOption;
                      this.reqitemOption = res.reqitemOption;
                  });
          }
      },
      InitData() {
          this.querymodOption = [];
          let modOption1 = localStorage.getItem("rm_Qmod_LIS611");
          let modOptions1 = JSON.parse(modOption1);
          if (modOptions1 != null) {
              this.querymodOption = XEUtils.clone(modOptions1, true);
          }

          this.stasticsmodOption = [];
          let modOption2 = localStorage.getItem("rm_Smod_LIS611");
          let modOptions2 = JSON.parse(modOption2);
          if (modOptions2 != null) {
              this.stasticsmodOption = XEUtils.clone(modOptions2, true);
          }
      },
      //查询模版选择
      querymodChange(value) {
          if (value) {
              let modList = localStorage.getItem("rm_Qmod_LIS611");
              let tempOption = JSON.parse(modList);
              this.querymodOption = tempOption;
              this.querymod = value;
              let obj = localStorage.getItem("rm_Qmod_LIS611_" + value);
              let jsondata = JSON.parse(obj);

              this.datetype = jsondata.datetype;
              this.datetime1 = jsondata.datetime1;
              this.datetime2 = jsondata.datetime2;
              this.pattype = jsondata.pattype;
              this.barcode_head = jsondata.barcode_head;
              this.rptunitid = jsondata.rptunitid;
              this.deptno = jsondata.deptno;
              this.wardno = jsondata.wardno;
              this.peformdept = jsondata.peformdept;
              this.pathospcode = jsondata.pathospcode;
              this.doctorno = jsondata.doctorno;
              this.reqtype = jsondata.reqtype;
              this.patsex = jsondata.patsex;
              this.groupna = jsondata.groupna;
              this.chkdeptno = jsondata.chkdeptno;
              this.chklabgroup = jsondata.chklabgroup;
              this.chkhospcode = jsondata.chkhospcode;
              this.reportusername = jsondata.reportusername;
              this.rechkusername = jsondata.rechkusername;
              this.diagnose = jsondata.diagnose;
              this.diagnoseicd = jsondata.diagnoseicd;
              this.sendhospcode = jsondata.sendhospcode;
              this.reqitem = jsondata.reqitem;
              this.reqstat = jsondata.reqstat;
              this.infocode = jsondata.infocode;
              this.emerflag = jsondata.emerflag == "1";
              this.unitgroup = jsondata.unitgroup;
              this.agelow = jsondata.agelow;
              this.ageupper = jsondata.ageupper;
              this.chargetype = jsondata.chargetype;
              this.exceptflag = jsondata.exceptflag;
              this.sampleno = jsondata.sampleno;
              this.chk_norec = jsondata.chk_norec;
              this.chk_abandon = jsondata.chk_abandon;
              this.chk_notcharge = jsondata.chk_notcharge;
              this.chk_notrpt = jsondata.chk_notrpt;
              this.chk_deptinput = jsondata.chk_deptinput;
              this.chk_bact = json.chk_bact;
              this.chk_detail = jsondata.chk_detail;
              this.showsum2 = jsondata.showsum2;
              this.showsum1 = jsondata.showsum1;
              this.infoitem = jsondata.infoitem;
              this.chkhospname = jsondata.chkhospname;
              this.doctorname = jsondata.doctorname;
              this.reportuserrealname = jsondata.reportuserrealname;
              this.peformdeptname = jsondata.peformdeptname;
              this.rechkuserrealname = jsondata.rechkuserrealname;
          }
      },
      //查询模版保存
      btnSavequerymod() {
          let jsondate = {
              datetype: this.datetype,
              datetime1: this.datetime1,
              datetime2: this.datetime2,
              pattype: this.pattype,
              barcode_head: this.barcode_head,
              rptunitid: this.rptunitid,
              deptno: this.deptno,
              wardno: this.wardno,
              peformdept: this.peformdept,
              pathospcode: this.pathospcode,
              doctorno: this.doctorno,
              reqtype: this.reqtype,
              patsex: this.patsex,
              groupna: this.groupna,
              chkdeptno: this.chkdeptno,
              chklabgroup: this.chklabgroup,
              chkhospcode: this.chkhospcode,
              reportusername: this.reportusername,
              rechkusername: this.rechkusername,
              diagnose: this.diagnose,
              diagnoseicd: this.diagnoseicd,
              sendhospcode: this.sendhospcode,
              reqitem: this.reqitem,
              reqstat: this.reqstat,
              infocode: this.infocode,
              emerflag: this.emerflag ? "1" : "0",
              unitgroup: this.unitgroup,
              exceptflag: this.exceptflag,
              chargetype: this.chargetype,
              agelow: this.agelow,
              ageupper: this.ageupper,
              sampleno: this.sampleno,
              chk_norec: this.chk_norec,
              chk_abandon: this.chk_abandon,
              chk_notcharge: this.chk_notcharge,
              chk_notrpt: this.chk_notrpt,
              chk_deptinput: this.chk_deptinput,
              chk_bact: this.chk_bact,
              chk_detail: this.chk_detail,
              showsum2: this.showsum2,
              showsum1: this.showsum1,
              infoitem: this.infoitem,
              chkhospname: this.chkhospname,
              doctorname: this.doctorname,
              reportuserrealname: this.reportuserrealname,
              peformdeptname: this.peformdeptname,
              rechkuserrealname: this.rechkuserrealname,
          };
          this.$prompt("查询模版保存名称", "文字编辑", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              // inputPattern: /^\s*$/g,
              // inputErrorMessage: "模版名称格式不正确"
          })
              .then(({ value }) => {
                  if (value && value.trim() != "") {
                      this.querymodOption = [];
                      let modOption = localStorage.getItem("rm_Qmod_LIS611");
                      let modOptions = JSON.parse(modOption);
                      let item = undefined;
                      if (modOptions != null) {
                          this.querymodOption = XEUtils.clone(modOptions, true);
                          item = modOptions.find((m) => m.value == value);
                      }
                      if (item != undefined) {
                      } else {
                          this.querymodOption.push({ label: value, value: value });
                      }
                      let modListJson = JSON.stringify(jsondate);
                      let modList = JSON.stringify(this.querymodOption);
                      localStorage.setItem("rm_Qmod_LIS611_" + value, modListJson);
                      localStorage.setItem("rm_Qmod_LIS611", modList);
                      this.querymod = value;
                  }
              })
              .catch(() => {
                  this.$message({
                      type: "info",
                      message: "取消输入",
                  });
              });
      },
      //查询模版删除
      btnDelquerymod() {
          this.$confirm("您确定删除查询模版：" + this.querymod + "吗？", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
          })
              .then(() => {
                  let value = this.querymod;
                  localStorage.removeItem("rm_Qmod_LIS611_" + value);
                  let modList = localStorage.getItem("rm_Qmod_LIS611");
                  let jsondate = JSON.parse(modList);
                  this.querymodOption = [];
                  jsondate.forEach((item) => {
                      if (item.value == value) {
                      } else {
                          this.querymodOption.push(item);
                      }
                  });
                  let newmodList = JSON.stringify(this.querymodOption);
                  localStorage.setItem("rm_Qmod_LIS611", newmodList);
                  this.querymod = "";
              })
              .catch(() => {});
      },
      //统计模版保存
      btnSaveStaticmod() {
          let jsondate = {
              chk_personnum: this.chk_personnum,
              chk_smpnum: this.chk_smpnum,
              chk_irptnum: this.chk_irptnum,
              chk_irtnum: this.chk_irtnum,
              chk_reportnum: this.chk_reportnum,
              chk_itemrechknum: this.chk_itemrechknum,
              tabledata: this.$refs.xTable2.tableData,
          };
          this.$prompt("统计模版保存名称", "文字编辑", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              // inputPattern: /^\s*$/g,
              // inputErrorMessage: "模版名称格式不正确"
          })
              .then(({ value }) => {
                  if (value && value.trim() != "") {
                      this.stasticsmodOption = [];
                      let modOption = localStorage.getItem("rm_Smod_LIS611");
                      let modOptions = JSON.parse(modOption);
                      let item = undefined;
                      if (modOptions != null) {
                          this.stasticsmodOption = XEUtils.clone(modOptions, true);
                          item = modOptions.find((m) => m.value == value);
                      }
                      if (item != undefined) {
                      } else {
                          this.stasticsmodOption.push({ label: value, value: value });
                      }
                      let modListJson = JSON.stringify(jsondate);
                      let modList = JSON.stringify(this.stasticsmodOption);
                      localStorage.setItem("rm_Smod_LIS611_" + value, modListJson);
                      localStorage.setItem("rm_Smod_LIS611", modList);
                      this.txtstasticsmod = value;
                  }
              })
              .catch(() => {
                  this.$message({
                      type: "info",
                      message: "取消输入",
                  });
              });
      },
      //统计模版删除
      btnDelStaticmod() {
          this.$confirm("您确定删除查询模版：" + this.txtstasticsmod + "吗？", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
          })
              .then(() => {
                  let value = this.txtstasticsmod;
                  localStorage.removeItem("rm_Smod_LIS611_" + value);
                  let modList = localStorage.getItem("rm_Smod_LIS611");
                  let jsondate = JSON.parse(modList);
                  this.stasticsmodOption = [];
                  jsondate.forEach((item) => {
                      if (item.value == value) {
                      } else {
                          this.stasticsmodOption.push(item);
                      }
                  });
                  let newmodList = JSON.stringify(this.stasticsmodOption);
                  localStorage.setItem("rm_Smod_LIS611", newmodList);
                  this.txtstasticsmod = "";
              })
              .catch(() => {});
      },
      //统计模版选择
      stasticmodChange(value) {
          this.resetStasticItem();
          let modList = localStorage.getItem("rm_Smod_LIS611");
          let tempOption = JSON.parse(modList);
          this.stasticsmodOption = tempOption;
          let obj = localStorage.getItem("rm_Smod_LIS611_" + value);
          let jsondate = JSON.parse(obj);
          this.$nextTick(() => {
              this.chk_personnum = jsondate.chk_personnum;
              this.chk_smpnum = jsondate.chk_smpnum;
              this.chk_irptnum = jsondate.chk_irptnum;
              this.chk_irtnum = jsondate.chk_irtnum;
              this.chk_reportnum = jsondate.chk_reportnum;
              this.chk_itemrechknum = jsondate.chk_itemrechknum;
              this.$refs.xTable2.tableData = jsondate.tabledata;
              setTimeout(() => {
                  let data = this.$refs.xTable2.tableData;
                  if (data.length != 0) {
                      this.currRowIndex = 0;
                      this.$refs.xTable2.setCurrentRow(data[0]);
                  }
              }, 10);
              jsondate.tabledata.forEach((item) => {
                  this[item.countcode] = true;
              });
          });
      },
      BtnPrint(btype) {
          let qwhere = "日期:" + XEUtils.toDateString(this.datetime1, "yyyy-MM-dd") + " - " + XEUtils.toDateString(this.datetime2, "yyyy-MM-dd");
          let qcol = this.infoitem;

          let footerData = {};
          let columns = this.$refs.xTable1.getColumns();
          columns.forEach((item, index) => {
              if (index === 0) {
                  footerData[item.property] = "总计";
              }
              let resdata = this.tableData.filter((x) => {
                  return x.color != "1" && x.color != "2";
              });

              if (["cp_amt", "cp_cnt", "cp_rs", "cp_samplecnt", "cp_itemrptcnt", "cp_itemfrecnt"].includes(item.property)) {
                  footerData[item.property] = XEUtils.sum(resdata, item.property).toFixed(2);
              } else if (index > 0) {
                  footerData[item.property] = "";
              }
          });

          var datas = XEUtils.clone(this.tableData);
          datas.push(footerData);
          this.$pub.PrintDynamicCol(this, "5081", datas, this.$refs.xTable1.getTableColumn().tableColumn, qwhere, qcol, btype);
      },
      footerMethod({ columns, data }) {
          return [
              columns.map((column, columnIndex) => {
                  if (columnIndex === 0) {
                      return "总计";
                  }
                  // if (["cp_samplecnt"].includes(column.property)) {
                  //     return this.SumAll(this.tableData, column.property);
                  //     //return this.$utils.sum(data, column.property);
                  // }

                  let resdata = data.filter((x) => {
                      return x.color != "1" && x.color != "2";
                  });
                  if (["cp_cnt", "cp_amt", "cp_rs", "cp_samplecnt", "cp_itemrptcnt", "cp_itemfrecnt"].includes(column.property)) {
                      return this.SumAll(resdata, column.property).toFixed(2);
                  }
                  // if (["cp_rs"].includes(column.property)) {
                  //     return this.SumAll(this.tableData, column.property);
                  // }
                  // if (["cp_renshu"].includes(column.property)) {
                  //     return this.SumAll(this.tableData, column.property);
                  // }
                  return null;
              }),
          ];
      },
      footerCellClassName({ $rowIndex, column, columnIndex }) {},
      SumAll(data, property) {
          var plus = 0;
          if (data) {
              for (let i = 0, len = data.length; i < len; i++) {
                  plus += data[i][property] - 0;
              }
          }

          return plus;
      },
      dialogItemChange({ row, rowIndex }) {
          this.currentindex = rowIndex;
      },
      dialogcountItemsave() {
          let data = this.$refs.xTable2.tableData;
          let res1 = "";
          let res2 = "";
          if (data.length > 0) {
              data.forEach((element) => {
                  if (res2 == "") {
                      res2 = element.countitem;
                      res1 = element.countcode;
                  } else {
                      res2 += "," + element.countitem;
                      res1 += "," + element.countcode;
                  }
                  this.tableColumn.push({
                      field: element.countcode,
                      title: element.countitem,
                  });
              });
          }
          this.infoitem = res2;
          this.infocode = res1;
          this.dialogcountItem = false;
      },
      chkcountitem(e, name, code) {
          let tablelist = this.$refs.xTable2.tableData;
          let ishave = tablelist.filter((m) => m.countcode == code);
          if (e) {
              if (tablelist.length <= 9) {
                  if (ishave.length == 0) {
                      this.$refs.xTable2.insert({ countitem: name, countcode: code }).then(({ row }) => {
                          this.$refs.xTable2.setCurrentRow(row).then(() => {
                              this.currentindex = this.$refs.xTable2.getRowIndex(this.$refs.xTable2.getCurrentRow());
                          });
                      });
                  }
              } else {
                  e = false;
                  this[code] = false;
                  this.$alert("您好，最多只能添加10条统计项目！", "提示", {
                      confirmButtonText: "确定",
                  });
              }
          } else {
              try {
                  if (ishave.length > 0) {
                      var rowindex = this.$refs.xTable2.getRowIndex(ishave[0]);
                      e = false;
                      this.$refs.xTable2.remove(ishave[0]);
                      let havedata = this.$refs.xTable2.tableData;
                      if (havedata.length > 0) {
                          if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                          let selectrow = havedata[rowindex];
                          this.$refs.xTable2.setCurrentRow(selectrow);
                      }
                  }
              } catch (e) {
                  console.log("error", e);
              }
          }
          if (code == "chkitemcode" && this.chkitemcode != "1") {
              this.chk_irptnum = false;
              this.chk_irtnum = false;
          }
      },
      rptChange(code) {
          if (this[code] == "1") {
              if (this.chkitemcode != "1") {
                  //项目代码未勾选，进行提示
                  this.$alert("勾选当前统计项前，必须先勾选：项目代码！", "提示", {
                      confirmButtonText: "确定",
                      showClose: false,
                  }).then(() => {
                      this.chk_irptnum = false;
                      this.chk_irtnum = false;
                  });
              }
          }
      },
      Btncountitem() {
          //重置所有选项
          this.resetStasticItem();
          this.txtstasticsmod = ""; 
          this.dialogcountItem = true;
          //表格及checkbox重新赋值
          setTimeout(() => {
              this.$refs.xTable2.tableData = [];
              if (this.infoitem != "") {
                  let name = this.infoitem.split(",");
                  let code = this.infocode.split(",");
                  let datas = this.$refs.xTable2.tableData;
                  for (let i = 0; i < name.length; i++) {
                      let finddatas = datas.filter((item) => item.countitem == name[i]);
                      if (finddatas.length == 0) {
                          this.$refs.xTable2.insert({ countitem: name[i], countcode: code[i] }).then(({ row }) => {
                              this.$refs.xTable2.setCurrentRow(row);
                          });
                          this.currRowIndex = name.length - 1;
                      }
                      this[code[i]] = true;
                  }
              }
          }, 20);
      },
      resetStasticItem() {
          this.chksendhospcode = false;
          this.chksenddeptno = false;
          this.chksenddoctor = false;
          this.chkpatwardno = false;
          this.chkexamgroup = false;
          this.chkitemspecimen = false;
          this.chkitemcode = false;
          this.chkitemname = false;
          this.chkitemprice = false;
          this.chkitemchargeflag = false;
          this.chkpatchargetype = false;
          this.chkpatchargeno = false;
          this.chkgroupna = false;
          this.chksaleman = false;
          this.chksampleuser = false;
          this.chkbarcode_head = false;
          this.chkexamhospcode = false;
          this.chkexlabgroup = false;
          this.chkviewhosp = false;
          this.chkexamdeptno = false;
          this.chkexamtptunit = false;
          this.chkverifydoctor = false;
          this.chkreportdoctor = false;
          this.chkpatsex = false;
          this.chkpattype = false;
          this.chkpatname = false;
          this.chkpatdianose = false;
          this.chkpatdianoseicd = false;
          this.chkpatid = false;
          this.chkpatno = false;
          this.chkbedno = false;
          this.chkpat_nationna = false;
          this.chkdateyear = false;
          this.chkdatemonth = false;
          this.chkdateday = false;
          this.chkhisrefcol1 = false;
          this.chkhisrefcol2 = false;
          this.chkhisrefcol3 = false;

          this.staticitemData = [];
      },
      SetFirst() {
          if (this.$refs.xTable2.getCurrentRow()) {
              var currentrow = this.$refs.xTable2.getCurrentRow();
              this.$refs.xTable2.tableData = this.$refs.xTable2.tableData.filter((item) => item._XID != currentrow._XID);
              this.$refs.xTable2.tableData.splice(0, 0, currentrow);
              this.currentindex = 0;
              this.$nextTick(() => {
                  this.$refs.xTable2.setCurrentRow(currentrow);
                  this.$refs.xTable2.scrollToRow(currentrow);
              });
          }
      },
      SetUp() {
          if (this.currentindex > 0) {
              var currentrow = this.$refs.xTable2.getCurrentRow();
              this.$refs.xTable2.tableData = this.$refs.xTable2.tableData.filter((item) => item._XID != currentrow._XID);
              this.$refs.xTable2.tableData.splice(this.currentindex - 1, 0, currentrow);
              this.currentindex -= 1;
              this.$nextTick(() => {
                  this.$refs.xTable2.setCurrentRow(currentrow);
                  this.$refs.xTable2.scrollToRow(currentrow);
              });
          }
      },
      SetDown() {
          if (this.currentindex >= 0 && this.currentindex < this.$refs.xTable2.tableData.length - 1) {
              var currentrow = this.$refs.xTable2.getCurrentRow();
              this.$refs.xTable2.tableData = this.$refs.xTable2.tableData.filter((item) => item._XID != currentrow._XID);
              this.$refs.xTable2.tableData.splice(this.currentindex + 1, 0, currentrow);
              this.currentindex += 1;
              this.$nextTick(() => {
                  this.$refs.xTable2.setCurrentRow(currentrow);
                  this.$refs.xTable2.scrollToRow(currentrow);
              });
          }
      },
      SetLast() {
          if (this.$refs.xTable2.getCurrentRow()) {
              var currentrow = this.$refs.xTable2.getCurrentRow();
              this.$refs.xTable2.tableData = this.$refs.xTable2.tableData.filter((item) => item._XID != currentrow._XID);
              this.$refs.xTable2.tableData.push(currentrow);
              this.currentindex = this.$refs.xTable2.tableData.length - 1;
              this.$nextTick(() => {
                  this.$refs.xTable2.setCurrentRow(currentrow);
                  this.$refs.xTable2.scrollToRow(currentrow);
              });
          }
      },
      popMultipleChk(e, fieldname, option, title) {
          var datatype = "";
          if (fieldname == "deptno") datatype = "Multi_dept";
          else if (fieldname == "rptunitid") datatype = "Multi_rptunitd";
          else if (fieldname == "wardno") datatype = "Multi_ward";
          else if (fieldname == "hospcode") datatype = "Multi_hospital";
          else if (fieldname == "sendhospcode") datatype = "Multi_hospital";
          else if (fieldname == "pathospcode") datatype = "Multi_hospital";
          else if (fieldname == "reqitem") datatype = "Multi_reqitem";
          this.multidatatype = datatype;
          if (datatype != "") {
              this.multivalue = e;
              this.option1 = [];
              this.option2 = [];
          } else {
              let temp = XEUtils.clone(option, true);
              this.option1 = [];
              this.option2 = [];
              if (e != "") {
                  let k = e.split(",");
                  k.forEach((item) => {
                      let ndata = temp.find((m) => m.data == item);
                      if (ndata != undefined && ndata != null) {
                          this.option2.push(ndata);
                      }
                  });
                  temp.forEach((item) => {
                      if (k.indexOf(item.data + "") < 0) {
                          this.option1.push(item);
                      }
                  });
              } else {
                  this.option1 = temp;
              }
          }
          this.fieldname = fieldname;
          this.multichktitle = title;
          this.dialogMultipleVisible = true;
      },
      closedialog(value, name) {
          if (value != "close") {
              this[name] = value;
          }
          this.dialogMultipleVisible = false;
      },
      DealDataStatic(all, second, first) {
          return all;
      },
      SumNum(data, object) {
          var num = 0;
          for (let i = 0; i < data.length; i++) {
              num += data[i][object] - 0;
          }
          return num;
      },
      CellClassName({ row, rowIndex, column, columnIndex }) {
          if (row.color == "1") return "col-green";
          if (row.color == "2") return "col-brown";
      },
      BtnExport() {
          var columns = XEUtils.clone(this.tableColumns, true);
          if (this.chk_cnt) columns.push({ field: "cp_cnt", title: "项次" });
          if (this.chk_amt) columns.push({ field: "cp_amt", title: "金额" });
          if (this.chk_personnum) columns.push({ field: "cp_rs", title: "人数" });
          if (this.chk_smpnum) columns.push({ field: "cp_samplecnt", title: "样本数" });
          if (this.chk_irptnum) columns.push({ field: "cp_itemrptcnt", title: "对应报告项目数" });
          if (this.chk_irtnum) columns.push({ field: "cp_itemfrecnt", title: "样本数*对应报告项目数" });
          let footerData = {};
          columns.forEach((item, index) => {
              if (index === 0) {
                  footerData[item.field] = "总计";
              }
              let resdata = this.tableData.filter((x) => {
                  return x.color != "1" && x.color != "2";
              });
              if (["cp_amt", "cp_cnt", "cp_rs", "cp_samplecnt", "cp_itemrptcnt", "cp_itemfrecnt"].includes(item.field)) {
                  footerData[item.field] = XEUtils.sum(resdata, item.field).toFixed(2);
              }
          });
          let datas = XEUtils.clone(this.tableData, true);
          datas.splice(datas.length, 0, footerData);
          let filtertxt = this.getExportFilter();
          this.$pub.exportTableExcel(datas, columns, "LIS611综合统计查询.xlsx", filtertxt, "统计条件：");
      },
      chkhospcodeChange(code, name) {
          this.chkhospcode = code;
          this.chkhospname = name;
      },
      doctornoChange(code, name) {
          this.doctorno = code;
          this.doctorname = name;
      },
      reportuserChange(code, name) {
          this.reportusername = code;
          this.reportuserrealname = name;
      },
      peformdeptChange(code, name) {
          this.peformdept = code;
          this.peformdeptname = name;
      },
      rechkuserChange(code, name) {
          this.rechkusername = code;
          this.rechkuserrealname = name;
      },
      // 获取当前导出文件的所有统计条件
      getExportFilter() {
          // 日期
          let datename = "";
          switch (this.datetype) {
              case "1":
                  datename = "接收时间";
                  break;
              case "2":
                  datename = "样本时间";
                  break;
              case "3":
                  datename = "生成时间";
                  break;
              case "4":
                  datename = "审核时间";
                  break;
          }
          let filtertxt = datename + ":" + XEUtils.toDateString(this.datetime1, "yyyy-MM-dd") + "至" + XEUtils.toDateString(this.datetime2, "yyyy-MM-dd") + "; ";
          if (this.querymod) filtertxt += "查询模板:" + this.getOptionName(this.querymodOption.filter((item) => ("," + this.querymod + ",").indexOf("," + item.value + ",") > -1)) + "; ";
          if (this.timevalue1) filtertxt += (this.exceptflag == "1" ? "剔除" : "") + "时间段:" + this.timevalue1 + "至" + this.timevalue2 + "; ";
          if (this.chkhospcode) filtertxt += "检验医院:" + this.chkhospname + "; ";
          if (this.chkdeptno) filtertxt += "检验科室:" + this.getOptionName(this.labdeptOption.filter((item) => ("," + this.chkdeptno + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.chklabgroup) filtertxt += "检验组别:" + this.getOptionName(this.labgroupOption.filter((item) => ("," + this.chklabgroup + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.sendhospcode) filtertxt += "送检医院:" + this.getOptionName(this.hospOption.filter((item) => ("," + this.sendhospcode + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.deptno) filtertxt += "申请科室:" + this.getOptionName(this.deptOption.filter((item) => ("," + this.deptno + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.emerflag == "1") filtertxt += "急诊" + "; ";
          if (this.rptunitid) filtertxt += "报告单元:" + this.getOptionName(this.rptunitOption.filter((item) => ("," + this.rptunitid + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.doctorno) filtertxt += "申请医生:" + this.doctorname + "; ";
          if (this.patsex) filtertxt += "性别:" + (this.patsex == "1" ? "男" : this.patsex == "2" ? "女" : "未知") + "; ";
          if (this.pattype) filtertxt += "病人类型:" + this.getOptionName(this.pattypeOption.filter((item) => ("," + this.pattype + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.wardno) filtertxt += "病区:" + this.getOptionName(this.wardOption.filter((item) => ("," + this.wardno + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.reqitem) filtertxt += "申请项目:" + this.getOptionName(this.reqitemOption.filter((item) => ("," + this.reqitem + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.reportusername) filtertxt += "检验医生:" + this.reportuserrealname + "; ";
          if (this.unitgroup) filtertxt += "单元组合:" + this.getOptionName(this.rptunitGroupOption.filter((item) => ("," + this.unitgroup + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.chargetype) filtertxt += "费别大类:" + this.getOptionName(this.chargetypeoption.filter((item) => ("," + this.chargetype + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.reqtype) filtertxt += "类别:" + (this.reqtype == "C" ? "检验" : "输血") + "; ";
          if (this.pathospcode) filtertxt += "所属院区:" + this.getOptionName(this.hospOption.filter((item) => ("," + this.pathospcode + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.peformdept) filtertxt += "执行科室:" + this.peformdeptname + "; ";
          if (this.reqstat) filtertxt += "状态:" + this.getReqStatName(this.reqstat) + "; ";
          if (this.groupna) filtertxt += "分单类别:" + this.getOptionName(this.reqgroupOption.filter((item) => ("," + this.groupna + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.agelow) filtertxt += "年龄区间:" + this.agelow + "至" + this.ageupper + "; ";
          if (this.sampleno) filtertxt += "标本号区间:" + this.sampleno + "; ";
          if (this.rechkusername) filtertxt += "审核医生:" + this.rechkuserrealname + "; ";
          if (this.diagnose) filtertxt += "病人诊断:" + this.diagnose + "; ";
          if (this.diagnoseicd) filtertxt += "诊断ICD:" + this.diagnoseicd + "; ";
          if (this.barcode_head) filtertxt += "条码前缀:" + this.getOptionName(this.barcode_headOption.filter((item) => ("," + this.barcode_head + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.infoitem) filtertxt += "统计项目:" + this.infoitem + "; ";
          if (this.sel_mixrpt) filtertxt += "混样报告:" + (this.sel_mixrpt == "0" ? "全部报告" : this.sel_mixrpt == "1" ? "混样主报告" : "混样明细报告") + "; ";
          let notattxt = "";
          if (this.chk_norec == "1") notattxt += "未接收、";
          if (this.chk_abandon == "1") notattxt += "作废退回、";
          if (this.chk_notcharge == "1") notattxt += "未计价、";
          if (this.chk_notrpt == "1") notattxt += "未报告、";
          if (this.chk_deptinput == "1") notattxt += "科内录入、";
          if (this.chk_bact == "1") notattxt += "无纸化微生物、";
          if (notattxt) filtertxt += notattxt.substring(0, notattxt.length - 1) + "的标本不统计;";
          let daytxt = "";
          if (this.chk_workdays == "1") daytxt += "工作日、";
          if (this.chk_holiday == "1") daytxt += "节假日、";
          if (this.chk_saturday == "1") daytxt += "周六、";
          if (this.chk_sunday == "1") daytxt += "周日、";
          if (this.chk_cnt) daytxt += "项次、";
          if (this.chk_amt) daytxt += "金额、";
          if (daytxt) filtertxt += "统计包含" + daytxt.substring(0, daytxt.length - 1) + "; ";
          if (this.chk_detail == "1") filtertxt += "按小项统计;";
          if (this.showsum2 == "1") filtertxt += "显示小计;";
          if (this.showsum1 == "1") filtertxt += "显示合计;";
          return filtertxt;
      },
      getReqStatName(reqstat) {
          let reqstatname = "";
          switch (reqstat) {
              case "0":
                  reqstatname = "申请";
                  break;
              case "1":
                  reqstatname = "打印";
                  break;
              case "2":
                  reqstatname = "采样";
                  break;
              case "3":
                  reqstatname = "护士站送出";
                  break;
              case "4":
                  reqstatname = "检验科签收";
                  break;
              case "01":
                  reqstatname = "申请单已被审核";
                  break;
              case "02":
                  reqstatname = "申请单审核未通过";
                  break;
              case "03":
                  reqstatname = "复审通过";
                  break;
              case "04":
                  reqstatname = "复审未通过";
                  break;
              case "12":
                  reqstatname = "打印复核";
                  break;
              case "31":
                  reqstatname = "已下载";
                  break;
              case "41":
                  reqstatname = "工作组签收";
                  break;
              case "42":
                  reqstatname = "上机";
                  break;
              case "43":
                  reqstatname = "组内交接";
                  break;
              case "44":
                  reqstatname = "已分样";
                  break;
              case "45":
                  reqstatname = "外送送出";
                  break;
          }
          return reqstatname;
      },
      getOptionName(option) {
          if (option && option.length > 0) {
              let optionname = "";
              option.forEach((item) => {
                  if (item.hasOwnProperty("display")) {
                      optionname += item.display + ",";
                  } else {
                      optionname += item.label + ",";
                  }
              });
              return optionname.substring(0, optionname.length - 1);
          } else {
              return "";
          }
      },
  },
};
</script>

<style scoped>
.pagetop {
  width: 100%;
  height: 258px;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
  overflow-x: auto;
}
::-webkit-scrollbar {
  width: 0px;
  height: 5px;
  border: 4px solid white;
}
::-webkit-scrollbar-thumb {
  background-color: #c1c1c1;
}
::-webkit-scrollbar-track {
  background-color: #f1f1f1;
}
/* Buttons */
::-webkit-scrollbar-button:single-button {
  background-color: #bbbbbb;
  display: block;
  border-style: solid;
  height: 5px;
  width: 5px;
}
/* Left */
::-webkit-scrollbar-button:horizontal:decrement {
  margin-right: 2px;
  border-width: 4px 4px 4px 0;
  border-color: #f1f1f1 transparent #f1f1f1 #f1f1f1;
  background-color: #000000;
}
::-webkit-scrollbar-button:horizontal:decrement:hover {
  border-color: #d2d2d2 transparent #d2d2d2 #d2d2d2;
}
/* Right */
::-webkit-scrollbar-button:horizontal:increment {
  margin-left: 2px;
  border-width: 4px 0 4px 4px;
  border-color: #f1f1f1 #f1f1f1 #f1f1f1 transparent;
  background-color: #000000;
}
::-webkit-scrollbar-button:horizontal:increment:hover {
  border-color: #d2d2d2 #d2d2d2 #d2d2d2 transparent;
}
::v-deep .pagetop .el-radio {
  margin-right: 8px !important;
}
::v-deep .pagetop .el-radio__label {
  padding-left: 2px !important;
}
.pagetop .el-checkbox {
  margin-left: 3px;
}
::v-deep .pagetop .el-checkbox__label {
  padding-left: 2px !important;
}
.pagetop-content {
  height: 100%;
  width: 100%;
  min-width: 1260px;
}
.top-btn {
  background-color: #e6e6e6;
  color: black;
  margin-left: 3px;
}
.mychkclass .el-checkbox {
  margin-right: 5px !important;
}
::v-deep .mychkclass .el-divider--vertical {
  margin: 0 8px !important;
}

.pagecenter {
  position: absolute;
  top: 261px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}
table tr td:nth-child(1) {
  width: 65px;
}
.left_nav {
  width: 20%;
  height: 100%;
  border-right: 1px solid #ccc;
  padding: 0px 0px 0px 0px;
  /* float: left; */
  display: inline-block;
}
.left_nav div {
  cursor: pointer;
  height: 40px;
  width: 100%;
  float: left;
  padding-left: 20px;
  line-height: 40px;
}
.left_nav .active {
  background-color: DeepSkyBlue;
}
.right_nav {
  width: 80%;
  height: 100%;
  display: inline-block;
  vertical-align: top;
  /* float: left; */
  display: inline-block;
}
::v-deep .el-input--suffix .el-input__inner {
  padding-right: 10px;
}
::v-deep .col-green {
  color: green !important;
}
::v-deep .col-brown {
  color: brown !important;
}
</style>
